package com.juyu.miliao.api.rabbitMQ;

import com.alibaba.fastjson.JSONObject;
import com.juyu.miliao.api.domain.OfficialQuestionToAnswerInfo;
import com.juyu.miliao.common.constant.OfficialAnswerRabbitMqInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 官方回答队列
 *
 * @author xuanqicheng
 * @create 2018-24-11:04
 */
@Component
@Slf4j
public class OfficialQuestionToAnswerRabbitMq {

    @Autowired
    private AmqpTemplate amqpTemplate;

    /**
     * 更新
     * @param officialQuestionToAnswerInfo
     */
    public void deleteQfficialAnswerInfo(OfficialQuestionToAnswerInfo officialQuestionToAnswerInfo){

        if(officialQuestionToAnswerInfo!=null){
            amqpTemplate.convertAndSend(OfficialAnswerRabbitMqInfo.EXCHANGE_TO_OFFICIAL_ANSWER_EXCHANGE,
                    OfficialAnswerRabbitMqInfo.ROUTING_KEY_TO_UPDATE_OFFICIAL_ANSWER,
                    JSONObject.toJSONString(officialQuestionToAnswerInfo));
        }
    }
}
